package com.powernode.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.powernode.domain.Member;
import com.powernode.mapper.MemberMapper;
import com.powernode.service.MemberService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.powernode.util.AuthUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author 付作巍
 * @since 2024-08-19
 */
@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements MemberService {

    @Autowired
    private MemberMapper memberMapper;

    /**
     * 更新会员的头像和昵称
     * @param member 会员对象
     * @return
     */
    @Override
    public Boolean modifyMemberInfoByOpenId(Member member) {
        // 获取当前用户的openId
        String openId = AuthUtils.getMemberOpenId();
        // 更新会员的头像和昵称
        return memberMapper.update(member,new LambdaQueryWrapper<Member>()
                .eq(Member::getOpenId,openId)
        ) > 0;
    }


}
